#include <stdio.h>
#include <wiringPi.h>
#include <softPwm.h>

#define KEY1 24
#define KEY2 25
#define KEY3 0
#define KEY4 1

void KEY1_Interrupt(void);
void KEY2_Interrupt(void);
void KEY3_Interrupt(void);
void KEY4_Interrupt(void);

int main(int argc, char *argv[]){
    if(wiringPiSetup() == -1){		//初始化必须写在最前边
    
        printf("setup wiringPi failed !");
        return 1;
    }
    printf("Hello World!\n");
    if(wiringPiISR(KEY1,INT_EDGE_FALLING,&KEY1_Interrupt) < 0){
        printf("Unable to setup ISR\n");
    }
    if(wiringPiISR(KEY2,INT_EDGE_FALLING,&KEY2_Interrupt) < 0){
        printf("Unable to setup ISR\n");
    }
    if(wiringPiISR(KEY3,INT_EDGE_FALLING,&KEY3_Interrupt) < 0){
        printf("Unable to setup ISR\n");
    }
    if(wiringPiISR(KEY4,INT_EDGE_FALLING,&KEY4_Interrupt) < 0){
        printf("Unable to setup ISR\n");
    }
    while(1){}
    return 0;
}

void KEY1_Interrupt(void) //按键1中断服务程序
{
    printf("Key1\n");
}

void KEY2_Interrupt(void) //按键2中断服务程序
{
    printf("Key2\n");
}

void KEY3_Interrupt(void) //按键3中断服务程序
{
    printf("Key3\n");
}

void KEY4_Interrupt(void) //按键4中断服务程序
{
    printf("Key4\n");
}


